module.exports = () => {
    return async function toHttps(ctx, next) {

        if (ctx.protocol === 'https')
            await next();
        else {
            if (ctx.request.method == 'GET')
                ctx.redirect('https://' + ctx.headers.host + ctx.originalUrl);
            else
                ctx.body = '非法访问';
        }

    };
};